<?php
$glideName = "glide_" . rand(0, 100);

$script.="featuredcontentglider.init({";
$script.="gliderid: \"$glideName\","; //ID of main glider container
$script.="contentclass: \"glidecontent\","; //Shared CSS class name of each glider content
$script.="togglerid: \"p-select\","; //ID of toggler container
$script.="remotecontent: \"\","; //Get gliding contents from external file on server? "filename" or "" to disable
$script.="selected: 0,"; //Default selected content index (0=1st)
$script.="persiststate: false,"; //Remember last content shown within browser session (true/false)?
$script.="speed: $SPEED,"; //Glide animation duration (in milliseconds)
$script.="direction: \"$MOVE\","; //set direction of glide: "updown", "downup", "leftright", or "rightleft"
$script.="autorotate: true,"; //Auto rotate contents (true/false)?
$script.="autorotateconfig: [7000, 30]"; //if auto rotate enabled, set [milliseconds_btw_rotations, cycles_before_stopping]
$script.="})";
?>
<div id="<?php echo $glideName ?>" class="glidecontentwrapper">
    <?php
    $toggler = "";
    $GLIDE_LIMIT = 5;
    $queryResult = $cquery->showByGroup($GROUP_ID, "resource", "rand", true);
    $i = 0;

    $cnt = 0;
    foreach ($queryResult as $group) {
        if (strlen($group["group_member_resource"]) > 0) {
            $imageURL = $cquery->getResourceDetails($group["group_member_resource"]);
        } else {
            $imageURL = $cquery->getFirstResourceContent($group["content_id"]);
        }
        if (strlen($group["content_id"]) > 0 && is_null($group["group_member_title"])) {
            $pg = $cquery->getContentDetails($group["content_id"]);
            foreach ($pg as $content) {
                $title = $content["page_title"];
            }
            //  $rs =$cquery->
        } else {
            $title = $group["group_member_title"];
        }
    ?>
        <div class="glidecontent">
        <?php
        $toggler.="<a class='toc' href='#' pagenumber='" . $cnt . "pg'>$title</a>";
        if (strlen($group["content_id"]) > 0)
            $link = $cquery->fxn->processURL("page", $group["content_id"], $title, $group["group_direct_link"]);
        else
            $link=$group["group_direct_link"] . "#";

        $cnt++;
        ?>

        <div class="htxt"><h1><?php echo $title; ?></h1>
<?php echo $group["description"]; ?></div>

<?php if (strlen($imageURL) > 0) {
?>
        <a href="<?php echo $link ?>"  title="<?php echo $group["resource_description"]; ?>" >
<?php echo $cquery->fxn->processResources($imageURL, $title); //"<img name='' src='".$HOME_URL."resources/".$imageURL."'  alt='". $group["resource_description"]."' class='imgleft border2' />";  ?>

        </a>
<?php } ?>

    </div>

<?php } ?>

    <div class="glidecontenttoggler" id="p-select" style="display: block;">
      
<?php echo $toggler; ?>
         <a class="next" href="#" loadpage="0pg">»</a> <a class="prev" href="#" buttontype="previous" loadpage="0pg"> « </a>

    </div>

    <div class="clear"></div>
</div>